package com.ljw.test;

import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.ljw.test.model.Child;
import com.ljw.test.util.GreenDaoManager;
import com.ljw.test.view.WordWrapView;

import java.util.List;


public class MainActivity extends Activity implements View.OnClickListener {
    private WordWrapView wordWrapView;
    private LinearLayout sentimene2;
    private Button button,b1,b2;
    private EditText edit;
    private GreenDaoManager manager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.settings_view);

        initView();
    }

    private void initView() {
        manager = GreenDaoManager.getInstance();
        button = (Button) findViewById(R.id.button);
        edit = (EditText) findViewById(R.id.edit);
        button.setOnClickListener(this);
        edit.setOnClickListener(this);


    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.button:
                List<Child> children = manager.queryChildren(edit.getText().toString()).getChildList();
                for (Child child : children) {
                    System.out.println(child.toString());
                }
                break;

        }
    }

    @Override
    protected void onStart() {
        super.onStart();
        finish();
    }


    public void button1(View view) {
        Toast toast = Toast.makeText(MainActivity.this, "String", Toast.LENGTH_LONG);
        toast.setGravity(Gravity.TOP,0,0);
        toast.show();
    }
}
